package _220327;

/**
 * @author ShadowLim
 * @create 2022-03-27-8:10
 */
public class 七星填数 {
    static int[] arr = {1,2,3,4,5,7,8,9,10,12,13};

    public static void main(String[] args) {
        dfs(arr, 0);
    }

    private static void dfs(int[] arr, int k) {
        if (k == arr.length) {
            int sum1 = arr[0] + arr[1] + arr[2] + arr[3];
            int sum2 = 6  + arr[2] + arr[4] + 11;
            int sum3 = arr[3] + arr[4] + arr[5] + arr[6];
            int sum4 = 6 + arr[1] + arr[9] + 14;
            int sum5 = arr[0] + arr[9] + arr[8] + arr[10];
            int sum6 = arr[10] + arr[7] + arr[5] + 11;
            int sum7 = arr[6] + arr[7] + arr[8] + 14;
            if (sum1 == sum2 && sum1 == sum3 && sum1 == sum4 && sum1 == sum5 &&
                    sum1 == sum6 && sum1 == sum7) {
                System.out.println(arr[0] + " " + arr[1] + " " + arr[2] + " " + arr[3]);
                System.exit(0);
                return;
            }
            return;
        }
        for (int i = k; i < arr.length; i++) {
            int temp = arr[i];
            arr[i] = arr[k];
            arr[k] = temp;
            dfs(arr, k + 1);
            temp = arr[i];
            arr[i] = arr[k];
            arr[k] = temp;
        }
    }
}
